<?php
namespace TeamPlayers;

class authenticationController{
	
	function __construct(){
		
		if(method_exists($this, strtolower($_GET['method']))){
				call_user_func(array($this, strtolower($_GET['method'])));
		} else {
					
		}
			
	}
	
	public function logout(){
	TeamPlayers::$ac->logout();
		header("location:http://teamplayers.dev", 303);
	}
	
	public function loginScreen(){
		TeamPlayers::$smarty->display("userManagement/login.tpl");
	}
	
	public function registerUser(){
		TeamPlayers::$smarty->display("userManagement/registerUser.tpl");
	}
	
	/**
	 * 
	 * Recieves post data from the user registration form and creates a new user in the system
	 * @todo do form checks to see that all variables are posted correctly 
	 */
	public function createUser(){
		$name = $_POST['firstname']. " " . $_POST['lastname']; 
		TeamPlayers::$ac->createUser( $_POST['email'], $_POST['email'], $_POST['password'], $name, $_POST['phone'], $status = 'pending' );
		TeamPlayers::$smarty->display("userManagement/emailSendt.tpl");
	}
	
}

?>